master @ 54 LINES
[ HISTORY ] [ UP ]
┌─ ASTRO ────────────────────────────────────────────────────────────────────┐
│ --- │
│ // Legacy URL. The Total Runs view now lives on the unified Players page │
│ // at /challenge-mode/all-time/{players|characters}/{scope}?sort=runs. │
│ // Redirect old links so bookmarks keep working. │
│ import { CLASSES } from "../../../../lib/wow-constants"; │
│ │
│ const scope = Astro.params.scope || ""; │
│ const scopeParts = scope.split("/").filter(Boolean); │
│ const viewParam = Astro.url.searchParams.get("view"); │
│ │
│ let region = ""; │
│ let realm = ""; │
│ let classKey = ""; │
│ │
│ // Old shape: /total-runs/{region|global}[/{realm}][/{class}] OR │
│ // /total-runs/{region|global}[/{class}] │
│ if (scopeParts.length >= 1) { │
│ region = scopeParts[0]; │
│ if (region === "global") { │
│ region = ""; │
│ if (scopeParts.length >= 2) classKey = scopeParts[1]; │
│ } else if (scopeParts.length >= 2) { │
│ const second = scopeParts[1]; │
│ if (CLASSES.includes(second as any)) { │
│ classKey = second; │
│ } else { │
│ realm = second; │
│ if (scopeParts.length >= 3) classKey = scopeParts[2]; │
│ } │
│ } │
│ } │
│ │
│ // Class scope only exists on the character view (accounts span classes). │
│ // If a class was provided, force character view regardless of `?view=`. │
│ const view: "player" | "character" = │
│ classKey || viewParam === "character" ? "character" : "player"; │
│ │
│ const segs: string[] = []; │
│ if (region) { │
│ segs.push(region); │
│ if (realm) segs.push(realm); │
│ if (classKey && view === "character") segs.push(classKey); │
│ } else { │
│ segs.push("global"); │
│ if (classKey && view === "character") segs.push(classKey); │
│ } │
│ │
│ const target = `/challenge-mode/all-time/${ │
│ view === "player" ? "players" : "characters" │
│ }/by-runs/${segs.join("/")}`; │
│ │
│ return Astro.redirect(target, 301); │
│ --- │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ASTRO ──────────────────────────────┐
│ --- │
│ // Legacy URL. The Total Runs view now lives │
│ on the unified Players page │
│ // at /challenge-mode/all-time/{players|char │
│ acters}/{scope}?sort=runs. │
│ // Redirect old links so bookmarks keep work │
│ ing. │
│ import { CLASSES } from "../../../../lib/wow │
│ -constants"; │
│ │
│ const scope = Astro.params.scope || ""; │
│ const scopeParts = scope.split("/").filter(B │
│ oolean); │
│ const viewParam = Astro.url.searchParams.get │
│ ("view"); │
│ │
│ let region = ""; │
│ let realm = ""; │
│ let classKey = ""; │
│ │
│ // Old shape: /total-runs/{region|global}[/{ │
│ realm}][/{class}] OR │
│ // /total-runs/{region|global}[/{ │
│ class}] │
│ if (scopeParts.length >= 1) { │
│ region = scopeParts[0]; │
│ if (region === "global") { │
│ region = ""; │
│ if (scopeParts.length >= 2) classKey = s │
│ copeParts[1]; │
│ } else if (scopeParts.length >= 2) { │
│ const second = scopeParts[1]; │
│ if (CLASSES.includes(second as any)) { │
│ classKey = second; │
│ } else { │
│ realm = second; │
│ if (scopeParts.length >= 3) classKey = │
│ scopeParts[2]; │
│ } │
│ } │
│ } │
│ │
│ // Class scope only exists on the character │
│ view (accounts span classes). │
│ // If a class was provided, force character │
│ view regardless of `?view=`. │
│ const view: "player" | "character" = │
│ classKey || viewParam === "character" ? "c │
│ haracter" : "player"; │
│ │
│ const segs: string[] = []; │
│ if (region) { │
│ segs.push(region); │
│ if (realm) segs.push(realm); │
│ if (classKey && view === "character") segs │
│ .push(classKey); │
│ } else { │
│ segs.push("global"); │
│ if (classKey && view === "character") segs │
│ .push(classKey); │
│ } │
│ │
│ const target = `/challenge-mode/all-time/${ │
│ view === "player" ? "players" : "character │
│ s" │
│ }/by-runs/${segs.join("/")}`; │
│ │
│ return Astro.redirect(target, 301); │
│ --- │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET